<?php

class TagLibGx extends TagLib
{
    // 标签定义
    protected $tags = array(
        'channel' => array(
            'attr' => 'id,title,limit,order,item',
            'close' => 1,
        ),
    );

    public function _channel($attr, $content){
        $tag = $this->parseXmlAttr($attr, 'channel');

        $where=!empty($tag['id']) ? $tag['id']:$tag['title'];
        $limit=!empty($tag['limit']) ? $tag['limit']:0;
        $order=!empty($tag['order']) ? $tag['limit']:null;

        $m=M('channel')->where($where);
        if($limit)
            $m=$m->limit($limit);

        if($order)
            $m=$m->order($order);

        $items=$m->select();

        $parsestr="<foreach name='items' item='gx'>{$gx['title']}</foreach>";

        return $parsestr;
    }
}

?>